<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>这是睡眠的js</div>
<button onclick="test()">你就点吧</button>
</body>
</html>
<script>
    const config = {
        // delay: 3000
    }

    function sleep(delay) {
        let start = (new Date()).getTime();
        while ((new Date()).getTime() - start < delay) {
            continue;
        }
    }


    function handle() {
        let obj = {}
        obj.name = '张三'
        if (config.hasOwnProperty('delay')) {
            sleep(config.delay)
        }
        obj.sex = '男'
        return obj
    }


    function test() {
        const data = handle()
        console.log(data)
    }
</script>
